<template>
<nav class="app-topNav">
<div class="container">
  <ul>
    <template v-if="user.token">
      <li><a href="javascript:;"><i class="iconfont icon-user"></i>{{user.account}}</a></li>
      <li><a href="javascript:;" @click="logout">退出登录</a></li>
    </template>
   <template v-else>
     <li><router-link to="/login">请先登录</router-link></li>
     <li><a href="javascript:;">免费注册</a></li>
   </template>
    <li><a href="javascript:;">我的订单</a></li>
    <li><a href="javascript:;">会员中心</a></li>
    <li><a href="javascript:;">帮助中心</a></li>
    <li><a href="javascript:;">关于我们</a></li>
    <li><a href="javascript:;"><i class="iconfont icon-phone"></i>手机版</a></li>
  </ul>
</div>
</nav>
</template>
<script setup>
import {userUseStore} from "@/stores/user";
import router from "@/router";
import {useCartStore} from "@/stores/cart";

const userStore=userUseStore()
const user=userStore.user
const cartStore=useCartStore()
const logout=()=>{
  userStore.setUser({})
  router.push('/login')
  cartStore.setCartList([])
}
</script>
<style scoped lang="less">
.app-topNav{
  background-color: #333;
}
ul{
  display: flex;
  height: 53px;
  justify-content: flex-end;
  align-items: center;
  li{
    a{
      display: inline-block;
      padding:0 15px;
      color: #cdcdcd;
      i{
        font-size: 14px;
        margin-right: 2px;
      }
      &:hover{
        color: @xtxColor;
      }
    }
    ~ li {
      a {
        border-left: 2px solid #666;
      }
    }
  }
}
</style>
